<?php
/**
 *  前台基础类  
 * @see  ThePage.class.php
 * @version	1.0.0 (Tue Dec 27 10:49:15 CST 2011)
 * @author	sanshi
 */
//加载配置文件
include_once(dirname(dirname(__FILE__))."/common/config.inc.php");
//设置输出文件编码
header("content-type:text/html; charset=utf-8");
class ThePage
{
	var $smarty;
	var $userRequest;
	var $html_title="";
	var $id5_mc;
	function ThePage()
	{
		global $error_object,$memcacheConfig;
		//设置smarty前台使用常量
		$this->smarty = Factory::getSmarty();
		$this->smarty->template_dir = TPL_PATH."main/";
		$this->smarty->compile_dir = COM_PATH."main/";
		
		$this->userRequest = Factory::getBaseClass('UserRequest');
		//$this->id5_mc = Factory::getMemcached();
		//释放统计使用
		$this->smarty->assign('domain_name',DOMAIN_NAME);
		$this->smarty->assign('host_name',HOST_NAME);
		$this->smarty->assign("error_object",$error_object);
		$this->smarty->assign('css_path',CSS_PATH );
		$this->smarty->assign('js_path', JS_PATH);
		$this->smarty->assign('pic_path', PIC_PATH);
	}
	function set_title($title)
	{
		$this->smarty->assign("html_title",$this->html_title.$title);
	}
}

//设置日志使用函数
function user_log($u_id,$log_info,$log_type="error",$action_type)
{
	$temp['user_log_id'] = "";
	$temp['user_id'] = $u_id;
	$temp['log_action'] = $_SERVER['REQUEST_URI'];
	$temp['action_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] :"";
	$temp['log_time'] = time();
	$temp['log_type'] = $log_type;
	$temp['ip_address'] = getUserIP();
	$temp['log_inof'] = $log_info;
	$temp['req_data'] = serialize($_REQUEST);
	//print_r($temp);exit();
	if(defined('USER_USE_LOG4J') && USER_USE_LOG4J)
	{
		unset($temp['user_log_id']);
		include_once(LOG4J_PATH."Logger.php");
		Logger::configure(USER_LOG4J_CONFIG);
		$logger = Logger::getLogger($action_type);
		$temp['log_inof'] = json_encode($temp['log_inof']);
		$log_msg = implode('#||#',$temp);
		$logger->debug($log_msg);
	}
}
?>